const http = (obj) => {
	let baseUrl = '/api';
	return new Promise((resolve, reject) => {
		uni.request({
			// #ifdef MP-WEIXIN
			url: 'http://localhost:3000' + baseUrl + obj.url,
			// #endif
			// #ifndef MP-WEIXIN
			url: '/api' + baseUrl + obj.url,
			// #endif
			method: obj.method || 'GET',
			data: obj.data || {},
			header: obj.header || {
				'content-type': 'application/json'
			},
			success: res => {
				resolve(res);
			},
			fail: err => {
				reject(err);
			}
		})
	})
}

export default http;